package com.qzy.demo.mapper;

import com.qzy.demo.pojo.StudentPojo;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface StudentMapper {
    @Insert("INSERT INTO student(stuname,sex,address,birthday) "
            + "VALUES(#{stuname}, #{sex}, #{address},#{birthday})")
    void addStudent(StudentPojo studentPojo);

    @Delete("DELETE FROM student WHERE id=#{id}")
    void delStudent(Integer id);

    @Update("UPDATE student SET stuname=#{stuname} WHERE id=#{id}")
    void updStudent(StudentPojo studentPojo);

    @Select("SELECT * FROM student")
    @Results({
            @Result(property = "id",  column = "id"),
            @Result(property = "stuname",  column = "stuname"),
            @Result(property = "sex", column = "sex"),
            @Result(property = "address", column = "address"),
            @Result(property = "birthday", column = "birthday"),
    })
    List<StudentPojo> queryStudents();

    @Select("SELECT * FROM student WHERE id=#{id}")
    @Results({
            @Result(property = "id",  column = "id"),
            @Result(property = "stuname",  column = "stuname"),
            @Result(property = "sex", column = "sex"),
            @Result(property = "address", column = "address"),
            @Result(property = "birthday", column = "birthday"),
    })
    StudentPojo queryStudent(Integer id);
}
